package cn.saddyfire.pattern.facade;

import javax.jws.Oneway;

/**
 * @author Dee
 * @date 2024/2/4
 * <p>Description:外观类, 用户主要和该类进行交互
 */
public class SmartAppliancesFacade {
    //聚合电灯,电视机,空调
    private AirCondition airCondition;
    private Light light;
    private TV tv;

    public SmartAppliancesFacade() {
        airCondition = new AirCondition();
        light = new Light();
        tv = new TV();
    }
    //通过语音控制
    public void say(String message) {
        if (message.contains("打开")) {
            on();
        } else if (message.contains("关闭")) {
            off();
        } else {
            System.out.println("我还听不懂你说的!!!");
        }

    }

    private void off() {
        light.off();
        tv.off();
        airCondition.off();
    }

    private void on() {
        light.on();
        tv.on();
        airCondition.on();
    }
}
